# Durbin-Watson statistic
function s = dw(original, smoothed)
  n = length(original);
  d = original - smoothed;
  s = sum((d(2:end) - d(1:end-1)) .^ 2)/sum(d .^ 2);
  s = s*n/(n - 1);
endfunction
